package com.wdf.dota;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class ForumMenuActivity extends FragmentActivity {

	public static final String TAB_TOP10 = "精华";
	public static final String TAB_DISCUSSION = "讨论";
	public static final String TAB_ZHANSHU = "战术";
	public static final String TAB_TUCAO = "吐槽";
	public static final String TAB_TIETU = "贴图";

	public TabHost tabHost;
	LocalActivityManager activityManager;

	String loginName;
	String contactName;

	public RadioGroup radioGroup;

	String topic = TAB_TOP10;
	


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		super.onCreate(savedInstanceState);
		setContentView(R.layout.forum_menu);
		
    	try {

			tabHost = (TabHost) findViewById(android.R.id.tabhost);
			
			activityManager = new LocalActivityManager(ForumMenuActivity.this, false);  
	        activityManager.dispatchCreate(savedInstanceState);  
	        tabHost.setup(activityManager);  
		//	tabHost.setup();

			TabSpec ts1 = tabHost.newTabSpec(TAB_TOP10).setIndicator(TAB_TOP10);
			Intent intent1 = new Intent(ForumMenuActivity.this,
					ForumListActivity.class);
			Bundle bundle1 = new Bundle() ;
			bundle1.putString("topic", TAB_TOP10);
			intent1.putExtras(bundle1);
			ts1.setContent(intent1);
			tabHost.addTab(ts1);

			TabSpec ts2 = tabHost.newTabSpec(TAB_DISCUSSION).setIndicator(
					TAB_DISCUSSION);

			Intent intent2 = new Intent(ForumMenuActivity.this,
					ForumListActivity.class);
			Bundle bundle2 = new Bundle() ;
			bundle2.putString("topic", TAB_DISCUSSION);
			intent2.putExtras(bundle2);
			ts2.setContent(intent2);
			tabHost.addTab(ts2);

			TabSpec ts3 = tabHost.newTabSpec(TAB_ZHANSHU).setIndicator(
					TAB_ZHANSHU);
			Intent intent3 = new Intent(ForumMenuActivity.this,
					ForumListActivity.class);
			Bundle bundle3 = new Bundle() ;
			bundle3.putString("topic", TAB_ZHANSHU);
			intent3.putExtras(bundle3);
			ts3.setContent(intent3);
			tabHost.addTab(ts3);

			TabSpec ts4 = tabHost.newTabSpec(TAB_TUCAO).setIndicator(TAB_TUCAO);
			Intent intent4 = new Intent(ForumMenuActivity.this,
					ForumListActivity.class);
			Bundle bundle4 = new Bundle() ;
			bundle4.putString("topic", TAB_TUCAO);
			intent4.putExtras(bundle4);
			ts4.setContent(intent4);
			tabHost.addTab(ts4);
			
			/*
			TabSpec ts5 = tabHost.newTabSpec(TAB_TIETU).setIndicator(TAB_TIETU);
			Intent intent5 = new Intent(ForumMenuActivity.this,
					ForumListActivity.class);
			Bundle bundle5 = new Bundle() ;
			bundle5.putString("topic", TAB_TIETU);
			intent5.putExtras(bundle5);
			ts5.setContent(intent5);
			tabHost.addTab(ts5);
			
			*/

			this.radioGroup = (RadioGroup) findViewById(R.id.main_radio);
			radioGroup
					.setOnCheckedChangeListener(new OnCheckedChangeListener() {

						public void onCheckedChanged(RadioGroup group,
								int checkedId) {

							switch (checkedId) {
							case R.id.radio_button0:
								tabHost.setCurrentTabByTag(TAB_TOP10);
								break;
							case R.id.radio_button1:
								tabHost.setCurrentTabByTag(TAB_DISCUSSION);
								break;
							case R.id.radio_button2:
								tabHost.setCurrentTabByTag(TAB_ZHANSHU);
								
								break;
							case R.id.radio_button3:
								tabHost.setCurrentTabByTag(TAB_TUCAO);
								break;

							}
						}
					});

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);

	}
	
	@Override  
    protected void onPause() {  
        activityManager.dispatchPause(isFinishing());  
        super.onPause();  
    }  
  
    @Override  
    protected void onResume() {  
        activityManager.dispatchResume();  
        super.onResume();  
    }  
  
    @Override  
    public boolean onCreateOptionsMenu(Menu menu) {  
        // Inflate the menu; this adds items to the action bar if it is present.  
     //   getMenuInflater().inflate(R.menu.activity_main, menu);  
        return true;  
    }  

}